package cn.w2.demo1.aio.client;

import java.net.InetSocketAddress;
import java.nio.ByteBuffer;
import java.nio.channels.AsynchronousSocketChannel;
import java.nio.charset.Charset;
import java.util.concurrent.Future;

public class AioClient {
	public static void main(String[] args) throws Exception {
		AsynchronousSocketChannel socketChannel = AsynchronousSocketChannel.open();
		Future<Void> future = socketChannel.connect(new InetSocketAddress("127.0.0.1", 7397));
		System.out.println("itstack-demo-netty aio client start done. {关注公众号：bugstack虫洞栈 | 欢迎关注&获取源码}");
		future.get();
		socketChannel.read(ByteBuffer.allocate(1024), null,
				new AioClientHandler(socketChannel, Charset.forName("GBK")));
		Thread.sleep(100000);
	}
}
